@model ShoppingCartModel
@using Nop.Core
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@using Nop.Web.Models.ShoppingCart;
@{
   var webHelper = EngineContext.Current.Resolve<IWebHelper>();
}
<div class="order-summary-content">
   @Html.Widget("order_summary_content_before")
   @Html.Partial("_OrderReviewData", Model.OrderReviewData)
   @if (Model.Items.Count > 0)
   {
       if (Model.Warnings.Count > 0)
       {
       <div class="message-error">
           <ul>
               @foreach (var warning in Model.Warnings)
               {
                   <li>@warning</li>
               }
           </ul>
       </div>
       }     
       @*we add enctype = "multipart/form-data" because "File upload" attribute control type requires it*@
       using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post, new { enctype = "multipart/form-data", id = "shopping-cart-form" }))
       {
           @Html.AntiForgeryToken()
       <div class="table-wrapper">
           <table class="cart">
               <colgroup>
                   @if (Model.IsEditable)
                   {
                       <col width="1" />
                   }
                   @if (Model.ShowSku)
                   {
                       <col width="1" />
                   }
                   @if (Model.ShowProductImages)
                   {
                       <col width="1" />
                   }
                   <col />
                   <col width="1" />
                   <col width="1" />
                   <col width="1" />
               </colgroup>
               <thead>
                   <tr>
                       @if (Model.IsEditable)
                       {
                           <th class="remove-from-cart">
                               @T("ShoppingCart.Remove")
                           </th>
                       }
                       @if (Model.ShowSku)
                       {
                           <th class="sku">
                               @T("ShoppingCart.SKU")
                           </th>
                       }
                       @if (Model.ShowProductImages)
                       {
                           <th class="product-picture">
                               @T("ShoppingCart.Image")
                           </th>
                       }
                       <th class="product">
                           @T("ShoppingCart.Product(s)")
                       </th>
                       <th class="unit-price">
                           @T("ShoppingCart.UnitPrice")
                       </th>
                       <th class="quantity">
                           @T("ShoppingCart.Quantity")
                       </th>
                       <th class="subtotal">
                           @T("ShoppingCart.ItemTotal")
                       </th>
                   </tr>
               </thead>
               <tbody>
                   @foreach (var item in Model.Items)
                   {
                       <tr>
                           @if (Model.IsEditable)
                           {
                               <td class="remove-from-cart">
                                   <label class="td-title">@T("ShoppingCart.Remove"):</label>
                                   <input type="checkbox" name="removefromcart" value="@(item.Id)" />
                               </td>
                           }
                           @if (Model.ShowSku)
                           {
                               <td class="sku">
                                   <label class="td-title">@T("ShoppingCart.SKU"):</label>
                                    <span class="sku-number">@item.Sku</span>
                               </td>
                           }
                           @if (Model.ShowProductImages)
                           {
                               <td class="product-picture">
                                   <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })"><img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" /></a>
                               </td>
                           }
                           <td class="product">
                               <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" class="product-name">@item.ProductName</a>
                               @if (!String.IsNullOrEmpty(item.AttributeInfo))
                               {
                                   <div class="attributes">
                                       @Html.Raw(item.AttributeInfo)
                                   </div>
                               }
                               @if (!String.IsNullOrEmpty(item.RecurringInfo))
                               {
                                   <div class="recurring-info">
                                       @Html.Raw(item.RecurringInfo)
                                   </div>
                               }
                               @if (!String.IsNullOrEmpty(item.RentalInfo))
                               {
                                   <div class="rental-info">
                                       @Html.Raw(item.RentalInfo)
                                   </div>
                               }
                               @if (Model.IsEditable && item.AllowItemEditing)
                               {
                                   var editCartItemUrl = Url.RouteUrl("Product", new {SeName = item.ProductSeName});
                                   editCartItemUrl = webHelper.ModifyQueryString(editCartItemUrl, "updatecartitemid=" + item.Id, null);
                                   <div class="edit-item">
                                       <a href="@editCartItemUrl">@T("Common.Edit")</a>
                                   </div>
                               }
                               @if (item.Warnings.Count > 0)
                               {
                                   <div class="message-error">
                                       <ul>
                                           @foreach (var warning in item.Warnings)
                                           {
                                               <li>@warning</li>
                                           }
                                       </ul>
                                   </div>
                               }
                           </td>
                           <td class="unit-price">
                               <label class="td-title">@T("ShoppingCart.UnitPrice"):</label>
                               <span class="product-unit-price">@item.UnitPrice</span>
                           </td>
                           <td class="quantity">
                               <label class="td-title">@T("ShoppingCart.Quantity"):</label>
                               @if (Model.IsEditable)
                               {
                                   if (item.AllowedQuantities.Count > 0)
                                   {
                                       <select name="itemquantity@(item.Id)" class="qty-dropdown">
                                           @foreach (var qty in item.AllowedQuantities)
                                           {
                                               <option selected="@qty.Selected" value="@qty.Value">@qty.Value</option>
                                           }
                                       </select>
                                   }
                                   else
                                   {
                                       <input name="itemquantity@(item.Id)" type="text" value="@(item.Quantity)" class="qty-input" />
                                   }

                               }
                               else
                               {
                                    <span class="product-quantity">@item.Quantity</span>
                               }
                           </td>
                           <td class="subtotal">
                               <label class="td-title">@T("ShoppingCart.ItemTotal"):</label>
                               <span class="product-subtotal">@item.SubTotal</span>
                               @if (!String.IsNullOrEmpty(item.Discount))
                               {
                                   <div class="discount">
                                       @T("ShoppingCart.ItemYouSave"): @item.Discount
                                   </div>
                               }
                           </td>
                       </tr>
                   }
               </tbody>
           </table>
       </div>
        if (Model.IsEditable && Model.Items.Count > 0 && Model.DisplayTaxShippingInfo)
        {
            var inclTax = EngineContext.Current.Resolve<IWorkContext>().TaxDisplayType == TaxDisplayType.IncludingTax;
            //tax info is already included in the price (incl/excl tax). that's why we display only shipping info here
            //of course, you can modify appropriate locales to include VAT info there
        <div class="tax-shipping-info">
            @T(inclTax ? "ShoppingCart.TaxShipping.InclTax" : "ShoppingCart.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))
        </div>
        }
       <div class="cart-options">
           @if (Model.IsEditable)
           {
               <div class="common-buttons">
                   <input type="submit" name="updatecart" value="@T("ShoppingCart.UpdateCart")" class="button-2 update-cart-button" />
                   <input type="submit" name="continueshopping" value="@T("ShoppingCart.ContinueShopping")" class="button-2 continue-shopping-button" />
               </div>
           }
           @if (Model.IsEditable)
           {
               @Html.Partial("_CheckoutAttributes", Model.CheckoutAttributes, new ViewDataDictionary())
           }
           @if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
           {
               <div class="selected-checkout-attributes">
                   @Html.Raw(Model.CheckoutAttributeInfo)
               </div>
           }
       </div>
       <div class="cart-footer">
           @Html.Widget("order_summary_cart_footer")
           @if (Model.IsEditable)
           {
               <div class="cart-collaterals">
                   <div class="deals">
                       @Html.Partial("_DiscountBox", Model.DiscountBox)
                       @Html.Partial("_GiftCardBox", Model.GiftCardBox)
                       @Html.Widget("order_summary_content_deals")
                   </div>
                   @Html.Partial("EstimateShipping", Model.EstimateShipping)
               </div>
           }
           <div class="totals">
               @Html.Action("OrderTotals", "ShoppingCart", new { isEditable = Model.IsEditable })
               @if (Model.IsEditable)
               {
                   if (!String.IsNullOrEmpty(Model.MinOrderSubtotalWarning))
                   {
                       <div class="min-amount-warning">
                           @Model.MinOrderSubtotalWarning
                       </div>
                   }
               }
               @if (Model.IsEditable)
               {
                   if (Model.TermsOfServiceOnShoppingCartPage)
                   {
                       <div id="terms-of-service-warning-box" title="@T("Checkout.TermsOfService")" style="display: none;">
                           <p>@T("Checkout.TermsOfService.PleaseAccept")</p>
                       </div>
                       <div class="terms-of-service">
                           <input id="termsofservice" type="checkbox" name="termsofservice"/>
                           <span>
                                @T("Checkout.TermsOfService.IAccept")
                               <a class="read" id="read-terms">
                                    @T("Checkout.TermsOfService.Read")
                                </a>
                            </span>
                           <script>
                               $(document).ready(function() {
                                   $('#read-terms').on('click', function(e) {
                                       e.preventDefault();
                                       displayPopupContentFromUrl('@Url.RouteUrl("TopicPopup", new {SystemName = "conditionsofuse"})', '@T("Checkout.TermsOfService")');
                                   });
                               });
                           </script>
                       </div>
                   }
                   <div class="checkout-buttons">
                       @if (String.IsNullOrEmpty(Model.MinOrderSubtotalWarning))
                       {
                           <script type="text/javascript">
                               $(document).ready(function () {
                                   $('#checkout').click(function () {
                                       //terms of service
                                       var termOfServiceOk = true;
                                       if ($('#termsofservice').length > 0) {
                                           //terms of service element exists
                                           if (!$('#termsofservice').is(':checked')) {
                                               $("#terms-of-service-warning-box").dialog();
                                               termOfServiceOk = false;
                                           } else {
                                               termOfServiceOk = true;
                                           }
                                       }
                                       return termOfServiceOk;
                                   });
                               });
                           </script>
                           <button type="submit" id="checkout" name="checkout" value="checkout" class="button-1 checkout-button">
                               @T("Checkout.Button")
                           </button>
                       }
                   </div>
                   <div class="addon-buttons">
                       @*Payment method buttons (e.g. GoogleCheckoutButton, Paypal Express)*@
                       @Html.Partial("_ButtonPaymentMethod", Model)
                   </div>
               }
           </div>
       </div>
       if (Model.IsEditable)
       {
            @Html.Action("CrossSellProducts", "Product")
       }
       }
   }
   else
   {
       <div class="no-data">
           @T("ShoppingCart.CartIsEmpty")
       </div>
   }
   @Html.Widget("order_summary_content_after")
</div>